home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BBS Toolkit
/
BBS Toolkit.iso
/
wildcat
/
wc30rec.zip
/
BTREEO.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1992-05-12
|
5KB
|
141 lines
procedure CreateMsgStatusRec;
var
RefNr : LongInt;
MsgHeader : MsgStatusType;
LockStatus : Boolean;
begin
LockStatus := LockBTree(dbMsg);
with MsgHeader do
begin
Status := 0;
LowMsg := 0;
HighMsg := 0;
ActiveMsg := 0;
LastExtract := 0;
Len := 12;
Next := 0;
end;
BtAddRec(MsgFile, RefNr, MsgHeader);
if not IsamOk or (RefNr <> 1) then
LogFatalError('Unable to add message status record', IsamError);
if LockStatus then
UnLockBtree(dbMsg);
end;
procedure OpenMessageDatabase(MsgFilePath : IsamFileBlockName; Conf : Word);
var
IID : IsamIndDescr;
begin
MsgFilePath := MsgFilePath+'MSG'+LeftPadCh(Long2Str(Conf), '0', 3);
if not ExistFile(MsgFilePath+'.DAT') then
begin
IID[MsgNumberKey].KeyL := 2;
IID[MsgNumberKey].AllowDupK := False;
IID[MsgOrigNumKey].KeyL := 21;
IID[MsgOrigNumKey].AllowDupK := False;
IID[MsgDestNumKey].KeyL := 21;
IID[MsgDestNumKey].AllowDupK := False;
IID[MsgSubjectKey].KeyL := 21;
IID[MsgSubjectKey].AllowDupK := False;
IID[MsgReceiveKey].KeyL := 21;
IID[MsgReceiveKey].AllowDupK := False;
IID[MsgDeleteKey].KeyL := 2;
IID[MsgDeleteKey].AllowDupK := False;
BtCreateFileBlock(MsgFilePath, 512, 6, IID);
if IsamOk then
begin
OpenBtreeFile(MsgFile, MsgFilePath);
CreateMsgStatusRec;
end
else
LogFatalError('Unable to create conference '+Long2Str(Conf)+' message database', IsamError);
end
else
OpenBtreeFile(MsgFile, MsgFilePath);
if not IsamOk then
LogFatalError('Error opening conference '+Long2Str(Conf)+' message database', IsamError);
OpenDatabase[dbMsg] := True;
end;
procedure OpenUserDatabase;
var
RecSize : LongInt;
IID : IsamIndDescr;
DataBasePath : IsamFileBlockName;
begin
DataBasePath := Cfig.UserDataBasePath+'ALLUSERS';
if not ExistFile(DataBasePath+'.DAT') then
begin
IID[UserNameKey].KeyL := 19;
IID[UserNameKey].AllowDupK := False;
IID[UserSecKey].KeyL := 27;
IID[UserSecKey].AllowDupK := False;
IID[UserExpDateKey].KeyL := 2;
IID[UserExpDateKey].AllowDupK := True;
IID[UserAliasKey].KeyL := 19;
IID[UserAliasKey].AllowDupK := False;
BtCreateFileBlock(DataBasePath, UserRecSize + (Cfig.MaxConfAreas * SizeOf(ConfUserType)), 4, IID);
if not IsamOk then
LogFatalError('Unable to create user database', IsamError);
end;
OpenBtreeFile(UserFile, DataBasePath);
if not IsamOk then
LogFatalError('Unable to open user database', IsamError);
RecSize := BtDatRecordSize(UserFile);
if not IsamOk or (RecSize <> UserRecSize + (Cfig.MaxConfAreas * SizeOf(ConfUserType))) then
HaltWithError('User record size mismatch', '');
ReadMInfo(True);
MInfo.TotalUsers := BtreeUsedKeys(UserFile, UserNameKey);
WriteMInfo;
OpenDatabase[dbUser] := True;
end;
procedure OpenFileDatabase;
var
IID : IsamIndDescr;
DataBasePath : IsamFileBlockName;
begin
DataBasePath := Cfig.FileDataBasePath+'ALLFILES';
if not ExistFile(DataBasePath+'.DAT') then
begin
IID[FileNameKey].KeyL := 9;
IID[FileNameKey].AllowDupK := False;
IID[FileAreaKey].KeyL := 11;
IID[FileAreaKey].AllowDupK := False;
IID[FileDateKey].KeyL := 8;
IID[FileDateKey].AllowDupK := True;
IID[FilePWKey].KeyL := 10;
IID[FilePWKey].AllowDupK := False;
IID[FileUpKey].KeyL := 19;
IID[FileUpKey].AllowDupK := True;
IID[FileKWKey].KeyL := 8;
IID[FileKWKey].AllowDupK := True;
BtCreateFileBlock(DataBasePath, 297, 6, IID);
if not IsamOk then
LogFatalError('Unable to create file database', IsamError);
end;
OpenBtreeFile(FileSpec, DataBasePath);
if not IsamOk then
LogFatalError('Unable to open file database', IsamError);
ReadMInfo(True);
MInfo.TotalFiles := BtreeUsedKeys(FileSpec, FileNameKey);
WriteMInfo;
OpenDatabase[dbFile] := True;
end;
procedure OpenAllDatabases;
begin
if not OpenDatabase[dbUser] then
OpenUserDatabase;
if not OpenDatabase[dbFile] then
OpenFileDatabase;
end;